package com.itany.corejava.code11_IO.字符流;

import java.io.*;

/**
 * @author 石小俊
 * 2024年07月29日 16:06
 */
public class Test03_转换流 {

    public static void main(String[] args) {
        try {
            //InputStreamReader isr = new InputStreamReader(new FileInputStream("corejava/src/a.txt"));
            //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("corejava/src/a.txt")));
            // 在InputStreamReader的构造方法中,可以通过参数二指定字符集
            // 表示使用指定的字符集进行解析
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("corejava/src/a.txt"), "GBK"));
            PrintWriter out = new PrintWriter("corejava/src/aaaa.txt", "GBK");
            //BufferedWriter bw = new BufferedWriter(new FileWriter("corejava/src/aaaa.txt"));

            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
                //bw.write(line);
                //bw.flush();
                out.println(line);
                out.flush();
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
